package com.flying.compare.comparable;

import com.flying.compare.Product;
import org.junit.Test;

import java.util.Arrays;

/**
 * @author 刘鹏飞
 * @ClassName ComparableTest
 * @Date 2024/12/28 20:33
 * @Created by 刘鹏飞
 * @Description
 */
public class ComparableTest {


    /**
     * 测试自然排序
     */
    @Test
    public void test1() {

        Product banana = new Product("香蕉", 15.8);
        Product apple = new Product("香蕉", 10.0);
        Product grapes = new Product("香蕉", 25.0);
        Product orange = new Product("香蕉", 15.8);

        System.out.println(banana.compareTo(apple));

        Product[] products = {banana, apple, grapes, orange};

        System.out.println(Arrays.toString(products));

        Arrays.sort(products);

        System.out.println(Arrays.toString(products));


    }

}
